/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cp2013;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionListener;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author AcerXPS
 */
public class RechargeTokenUI extends JPanel{

    private JLabel lblRechargeAmt;
    private JTextField rechargeAmt;

    private JLabel lblPayType;
    private JTextField paymentType;

    private JLabel lblCardName;
    private JTextField cardName;

    private JLabel lblCardNum;
    private JTextField cardNumber;

    private JLabel lblCCV;
    private JTextField cCVCode;

    private JLabel lblValid;
    private JTextField validThru;

    private JButton btnSubmit;
    private JButton btnCancel;
    private File f;
    private BufferedImage img;

    @Override
    public void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.drawRenderedImage(img, AffineTransform.getTranslateInstance(0, 0));
    }
        
    public void initiateRechargeUI() {
        try{
            f = new File("Recharge.jpg");
            img = ImageIO.read(f);
        }catch (IOException ex){
            Logger.getLogger(RegisterUI.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
        setBackground(Color.white);
        setLayout(null);
        setAlignmentY(JPanel.CENTER_ALIGNMENT);
        initiateLabels();
        }
    }//end of initiateRechargeUI

    private void initiateLabels() {
        lblRechargeAmt = new JLabel("Recharge Amount ");
        lblRechargeAmt.setBounds(300, 100, 120, 15);
        rechargeAmt = new JTextField(15);
        getRechargeAmt().setBounds(410, 100, 120, 20);

        lblPayType = new JLabel("Payment Type: ");
        lblPayType.setBounds(300, 130, 120, 15);
        paymentType = new JTextField(15);
        getPaymentType().setBounds(410, 130, 120, 20);

        lblCardName = new JLabel("Name on Card: ");
        lblCardName.setBounds(300, 160, 120, 15);
        cardName = new JTextField(15);
        getCardName().setBounds(410, 160, 120, 20);

        lblCardNum = new JLabel("Card Number: ");
        lblCardNum.setBounds(300, 190, 120, 15);
        cardNumber = new JTextField(15);
        getCardNumber().setBounds(410, 190, 120, 20);

        lblCCV = new JLabel("CCV: ");
        lblCCV.setBounds(300, 220, 120, 15);
        cCVCode = new JTextField(3);
        getcCVCode().setBounds(410, 220, 40, 20);

        lblValid = new JLabel("Valid Thru: ");
        lblValid.setBounds(300, 250, 120, 15);
        validThru = new JTextField(5);
        getValidThru().setBounds(410, 250, 60, 20);
        
        btnSubmit = new JButton("Submit!");
        btnSubmit.setBounds(330, 280, 80, 20);
        btnCancel = new JButton("Cancel");
        btnCancel.setBounds(430, 280, 80, 20);

        add(lblRechargeAmt);
        add(getRechargeAmt());
        add(lblPayType);
        add(getPaymentType());
        add(lblCardName);
        add(getCardName());
        add(lblCardNum);
        add(getCardNumber());
        add(lblCCV);
        add(getcCVCode());
        add(lblValid);
        add(getValidThru());
        add(btnSubmit);
        add(btnCancel);
    }


    public JButton getBtnSubmit() {
        return btnSubmit;
    }

    public JButton getBtnCancel(){
        return btnCancel;
    }

    public void addListeners(ActionListener placeItemListener) {
        btnSubmit.addActionListener(placeItemListener);
        btnCancel.addActionListener(placeItemListener);
    }

    /**
     * @return the rechargeAmt
     */
    public JTextField getRechargeAmt() {
        return rechargeAmt;
    }

    /**
     * @return the paymentType
     */
    public JTextField getPaymentType() {
        return paymentType;
    }

    /**
     * @return the cardName
     */
    public JTextField getCardName() {
        return cardName;
    }

    /**
     * @return the cardNumber
     */
    public JTextField getCardNumber() {
        return cardNumber;
    }

    /**
     * @return the cCVCode
     */
    public JTextField getcCVCode() {
        return cCVCode;
    }

    /**
     * @return the validThru
     */
    public JTextField getValidThru() {
        return validThru;
    }


}
